<?php include('inc/functions.php'); ?>
<?php include('Games/data.php'); ?>
<?php $conn = getConnection();
	  $result = $conn->query('SELECT * FROM 2011_Games');
?>

<?php $section = 'Games'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Core[nerd]-Games</title>
<link href="inc/main.css" rel="stylesheet" type="text/css">
<style type="text/css">
</style>
<script type="text/javascript">
function warnToLogIn() {
	warning = "Please Login or Register before shopping!\n \n *register in \'Users\' tab";
	alert(warning);
}
</script>
</head>

<body>
<div id="container">

<?php include('inc/nav.php'); ?>
<h1>Games</h1>
<div id="games">
<ul>
<?php
while($rs = $result->fetch_assoc()) 
{
	$url = $rs['Image_url'];
?>
<li>
<div id="game-info">
	<?php echo '<img src="'.$url.'" />' ?>
    	<h3><?php echo $rs['Title']; ?></h3>
    	<p>Developer: <?php echo $rs['Developer']; ?></p>
    	<p>Genre: <?php echo $rs['Genre']; ?></p>
    	<p>ESRB Rating: <?php echo $rs['ESRB']; ?></p>
    	<p>Price: $<?php echo $rs['Price']; ?></p>
    	<?php
    		if (!isLoggedIn()) {
    			echo '<button id="submit" type="button" onclick="warnToLogIn()">add to cart</button>';
    		}
    		else { ?>
				<form action="cart.php" method="GET">
					<input type="hidden" name="new" value="<?=$rs['Title']?>">
		    		<input id="submit" type="submit" value="add to cart" >
		    	</form>';	  
		    <?php }
		?>
</div>
</li>
<?php
}
?>
</ul>
</div>

</div>
</body>

</html>
